﻿using System;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using SmlEngine.UI.Screens;

namespace SmlEngine.UI
{
    public class MenuEntry
    {
        public string Text { get; set; }

        public Action<MenuEntry> Selected { get; set; }
        public Action<MenuEntry> LeftPressed { get; set; }
        public Action<MenuEntry> RightPressed { get; set; }

        public bool IsChecked { get; set; }
        public bool IsEnabled { get; set; }

        internal bool StopFading { get; set; }

        public Vector2 Position { get; set; }
        public float Scale { get; set; }
        public Color Color { get; set; }

        public MenuEntry(string text, Action<MenuEntry> selected)
        {
            Text = text;
            Selected = selected;
            Scale = 1f;
            Color = Color.White;
        }

        internal void Left()
        {
            if (LeftPressed != null)
                LeftPressed(this);
        }

        internal void Right()
        {
            if (RightPressed != null)
                RightPressed(this);
        }

        public int GetWidth(SpriteFont font)
        {
            return (int)font.MeasureString(Text).X;
        }

        public int GetHeight(SpriteFont font)
        {
            return font.LineSpacing;
        }
    }
}
